package com.example.EventBusTest;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import org.simple.eventbus.EventBus;
import org.simple.eventbus.Subscriber;

/**
 * Created by Jaaksi on 2015/9/1.
 */
public class TargitActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EventBus.getDefault().registerSticky(this);
        setContentView(R.layout.activity_targit);

        // 不加tag的post
//        EventBus.getDefault().post(new Person("TargitActivity",20,21));
//        EventBus.getDefault().post(new Person("TargitActivity",20,21),"default_tag");
    }

    @Subscriber(tag = "Sticky")
    public void updateWidthTag(Person person) {
        String msg = "Sticky=" + person.toString();
        Log.i("fcy", msg);
        Toast.makeText(this,person.toString(),Toast.LENGTH_SHORT).show();
    }

    @Override
    protected void onDestroy() {
        EventBusTool.unregister(this);
        super.onDestroy();
    }
}